<?php
namespace Modules\Minicode\Http\Controllers;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Modules\Minicode\Entities\Shouye;
use Modules\Minicode\Http\Requests\ShouyeRequest;
class ShouyeController extends Controller
{
    //显示列表
    public function index()
    {
        $data = Shouye::paginate(10);
        return view('minicode::shouye.index', compact('data'));
    }

    //创建视图
    public function create(Shouye $shouye)
    {
        return view('minicode::shouye.create',compact('shouye'));
    }

    //保存数据
    public function store(ShouyeRequest $request,Shouye $shouye)
    {
        $shouye->fill($request->all());
        $shouye->save();

        return redirect('/minicode/shouye')->with('success', '保存成功');
    }

    //显示记录
    public function show(Shouye $field)
    {
        return view('minicode::shouye.show', compact('field'));
    }

    //编辑视图
    public function edit(Shouye $shouye)
    {
        return view('minicode::shouye.edit', compact('shouye'));
    }

    //更新数据
    public function update(ShouyeRequest $request, Shouye $shouye)
    {
        $shouye->update($request->all());
        return redirect('/minicode/shouye')->with('success','更新成功');
    }

    //删除模型
    public function destroy(Shouye $shouye)
    {
        $shouye->delete();
        return redirect('minicode/shouye')->with('success','删除成功');
    }
}
